//
//  YTOrderDetailBottomBtnView.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/8/17.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTOrderDetailBottomBtnView.h"

@implementation YTOrderDetailBottomBtnView

- (instancetype)initWithFrame:(CGRect)frame titles:(NSArray<NSString *> *)titles {
    self = [super initWithFrame:frame];
    if (self) {
        [self userinterfaceLayout:titles];
    }
    
    return self;
}

/** 布局*/
- (void)userinterfaceLayout:(NSArray<NSString *> *)titles {
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:leftBtn];
    [self configBtn:leftBtn textColor:kMainBlueColor backgroundColor:[UIColor whiteColor]];
    [leftBtn setTitle:titles[0] forState:UIControlStateNormal];
    [leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self);
        make.width.equalTo(self).multipliedBy(0.5);
    }];
    
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:rightBtn];
    [self configBtn:rightBtn textColor:[UIColor whiteColor] backgroundColor:kMainBlueColor];
    [rightBtn setTitle:titles[1] forState:UIControlStateNormal];
    [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.and.bottom.equalTo(self);
        make.width.equalTo(self).multipliedBy(0.5);
    }];
    @weakify(self);
    [leftBtn bk_whenTapped:^{
        @strongify(self);
        self.callBackAction(0);
    }];
    
    [rightBtn bk_whenTapped:^{
        @strongify(self);
        self.callBackAction(1);
    }];
    
}

/** 配置btn样式*/
- (void)configBtn:(UIButton *)btn
        textColor:(UIColor *)textColor
  backgroundColor:(UIColor *)backgroundColor {
    [btn setTitleColor:textColor forState:UIControlStateNormal];
    [btn setBackgroundColor:backgroundColor];
}

@end
